<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>js集合Set之遍历</title>
</head>
<body>
  <ul>
    <li>可使用keys(),values()获取Set的值，使用entries()获取键值对(键值相同)</li>
    <li>可使用forEach或for...of来遍历Set，注意forEach的参数(val,key)</li>
  </ul>
  <script>
    const set = new Set(['miracle', 'jack'])
    console.log(set.keys())    // SetIterator {"miracle", "jack"}
    console.log(set.values())  // SetIterator {"miracle", "jack"}
    console.log(set.entries()) // SetIterator {"miracle" => "miracle", "jack" => "jack"}
    set.forEach((val, key) => console.log(key, val))
    for (const item of set) {
      console.log(item)
    }
  </script>
</body>
</html>